package lanqiao;


import javax.swing.text.html.parser.Entity;
        import java.awt.*;
        import java.util.*;
        import java.util.Map.Entry;


public class test5 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();

        String[]str=new String[n];

        for (int i = 0; i < n; i++) {
            str[i]=scan.next();
        }
            Arrays.sort(str, new Comparator<String>() {
                @Override
                public int compare(String o1, String o2) {

                    return (o2+o1).compareTo(o1+o2);
                }
            });



        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < str.length; i++) {
            sb.append(str[i]);
        }

        String result=sb.toString();
        System.out.println(result);

    }
}
